.PHONY: all build clean run check cover lint docker help

BIN_FILE={{cookiecutter.app_name}}_api
BUILD_TIME=`date +%Y%m%d.%H%M`

build:
	@CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o "${BIN_FILE}"

run:
	@goctl api go -api ./api/api.api -dir . -style gozero --home $(PWD)/goctl_tpl
	@go run {{cookiecutter.app_name}}.go -f etc/{{cookiecutter.app_name}}-api.yaml

client:
	@goctl api ts -api ./api/admin.api  -dir  ./admin_api
gen:
	@goctl api go -api ./api/api.api -dir . -style gozero --home $(PWD)/goctl_tpl

doc:
	@goctl api doc --dir ./api/api.api  --o .

dbmodel:
	{% if cookiecutter.use_mysql == 'y' %}
	@goctl model mysql datasource -c --home $(PWD)/goctl_tpl  -table="reward,admin,notice" \
	-dir="./model/" -url="root:12345678@tcp(127.0.0.1:33061)/demo"
	{% endif %}
	{% if cookiecutter.use_mongo == 'y' %}
	@goctl model mongo --type User -dir="./model/" --cache
	{% endif %}
	

swagger:
	@goctl api plugin -plugin goctl-swagger="swagger -filename {{cookiecutter.app_name}}.json" -api ./api/doc.api -dir .
help:
	@echo "make 格式化go代码 并编译生成二进制文件"
	@echo "make build 编译go代码生成二进制文件"
	@echo "make clean 清理中间目标文件"
	@echo "make dbmodel 生成数据库模型"
	@echo "make doc 生成文档"
	@echo "make test 执行测试case"
	@echo "make check 格式化go代码"
	@echo "make cover 检查测试覆盖率"
	@echo "make run 直接运行程序"
	@echo "make lint 执行代码检查"
	@echo "make docker 构建docker镜像"
